From b6ad6fb47deb49b82b82e65c73590c6713a3d789 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Jun 2015 23:56:59 -0700 Subject: [PATCH] Filter statuses only by the relevant path This enables libgit2 to not traverse the majority of the tree, saving a lot of otherwise unnecessary syscalls. --- src/cargo/sources/path.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 80f919542..0e3668b42 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -153,6 +153,9 @@ impl<'cfg> PathSource<'cfg> { }); let mut opts = git2::StatusOptions::new(); opts.include_untracked(true); + if let Some(suffix) = util::without_prefix(pkg_path, &root) { + opts.pathspec(suffix); + } let statuses = try!(repo.statuses(Some(&mut opts))); let untracked = statuses.iter().map(|entry| { (join(&root, entry.path_bytes()), None) -- 2.30.2